package com.attendance.sz.utils;

import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Date;

public class logMa {
	private static boolean DEBUGBREAK = true;
	//private static final boolean SIMULATER = true;//false;//true;//模拟USB的出厂卡和生产卡,true为模拟，否则为真机
	private static final boolean DEBUG = true;//true;// 通过USB调试口输出
	//private static final boolean DEBUGNET = false;//true;// 通过网络输出
	
	public static void setDEBUGBREAK(boolean a) {
		DEBUGBREAK = a;
	}
	
	public static void d(String TAG, String method, String msg) {
		Log.d(TAG, "[" + method + "]" + msg);
	}

	public static void d(String TAG, String msg) {
		if (DEBUGBREAK){
			if (DEBUG) {
				Log.d(TAG, "[" + getFileLineMethod() + "]" + msg);
			}

		}
	}

	public static void dt(String TAG, String msg) {
		if (DEBUGBREAK) {
			
		}
		else{
			Log.d(TAG, "[" + getFileLineMethod() + "]" + msg);

		}
	}
	
	public static void d(String msg) {
		if (DEBUG) {
			Log.d(_FILE_(), "[" + getLineMethod() + "]" + msg);
		}
	}

	public static void e(String msg) {
		if (DEBUG) {
			Log.e(_FILE_(), getLineMethod() + msg);
		}
	}

	public static void e(String TAG, String msg) {
		if (DEBUG) {
			Log.e(TAG, getLineMethod() + msg);
		}
	}

	public static String getFileLineMethod() {
		StackTraceElement traceElement = ((new Exception()).getStackTrace())[2];
		StringBuffer toStringBuffer = new StringBuffer("[")
				.append(traceElement.getFileName()).append(" | ")
				.append(traceElement.getLineNumber()).append(" | ")
				.append(traceElement.getMethodName()).append("]");

		String strTime = "{" + _TIME_() + "}";

		return toStringBuffer.toString() + strTime;
	}

	public static String getLineMethod() {
		StackTraceElement traceElement = ((new Exception()).getStackTrace())[2];
		StringBuffer toStringBuffer = new StringBuffer("[")
				.append(traceElement.getLineNumber()).append(" | ")
				.append(traceElement.getMethodName()).append("]");
		return toStringBuffer.toString();
	}

	public static String _FILE_() {
		StackTraceElement traceElement = ((new Exception()).getStackTrace())[2];
		return traceElement.getFileName();
	}

	public static String _FUNC_() {
		StackTraceElement traceElement = ((new Exception()).getStackTrace())[1];
		return traceElement.getMethodName();
	}

	public static int _LINE_() {
		StackTraceElement traceElement = ((new Exception()).getStackTrace())[1];
		return traceElement.getLineNumber();
	}

	public static String _TIME_() {
		Date now = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		return sdf.format(now);
//		String strTemp;
//		String strt = sdf.format(now);
//		strt = strt.substring(20, 23);
//		String []strDa = new String[8];
//		ClsPublic.GetDateA(strDa);
//		strTemp = strDa[0]+"-"+strDa[1]+"-"+strDa[2]+" ";
//		strTemp +=strDa[3]+":"+strDa[4]+":"+strDa[5]+"."+strt;
//		
//		return strTemp;
		
	}


}
	
	